package com.jzwl.common.constant;

import java.net.URLDecoder;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jzwl.common.cache.RedisService;
import com.jzwl.common.init.infoholder.SystemInfoInitAndHolder;

/**
 * 可控制的常量类
 */
@Service("constants")
public class Constants {
	@Autowired
	private RedisService redisService;

	private String currentDB;

	public String getCurrentDB() {
		currentDB = (String) SystemInfoInitAndHolder.getSystemInfo("site_db");
		return currentDB;
	}

	//weixin
	private String xiaoka_weixin_appId;
	private String xiaoka_weixin_secret;
	private String xiaoka_weixin_token;
	private String xiaoka_weixin_aesKey;
	private String xiaoka_weixin_oauth2redirectUri;

	private String xiaoka_weixin_api_key;
	private String xiaoka_weixin_mch_id;
	private Long xiaoka_weixin_expiresTime;

	private String sftz_online_path;//七牛上传的地址
	private String sftz_image_path;//七牛下载文件的地址

	public String getRedisParamValue(String key) {
		String value = null;
		try {
			value = redisService.get(key);
			if (null != value && !"".equals(value)) {
				value = URLDecoder.decode(value, "utf-8");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return value;
	}

	public String getSftz_online_path() {
		sftz_online_path = (String) SystemInfoInitAndHolder.getSystemInfo("sftz_online_path");
		return sftz_online_path;
	}

	public void setSftz_online_path(String sftz_online_path) {
		this.sftz_online_path = sftz_online_path;
	}

	public String getSftz_image_path() {
		sftz_image_path = (String) SystemInfoInitAndHolder.getSystemInfo("sftz_image_path");
		return sftz_image_path;
	}

	public void setSftz_image_path(String sftz_image_path) {
		this.sftz_image_path = sftz_image_path;
	}

	public String getXiaoka_weixin_appId() {
		//		xiaoka_weixin_appId = getRedisParamValue("xiaoka_weixin_appId");
		//		if (StringUtil.isEmptyOrBlank(xiaoka_weixin_appId)) {
		xiaoka_weixin_appId = (String) SystemInfoInitAndHolder.getSystemInfo("xiaoka_weixin_appId");
		//		}
		return xiaoka_weixin_appId;
	}

	public void setXiaoka_weixin_appId(String xiaoka_weixin_appId) {
		this.xiaoka_weixin_appId = xiaoka_weixin_appId;
	}

	public String getXiaoka_weixin_secret() {
		//		xiaoka_weixin_secret = getRedisParamValue("xiaoka_weixin_secret");
		//		if (StringUtil.isEmptyOrBlank(xiaoka_weixin_secret)) {
		xiaoka_weixin_secret = (String) SystemInfoInitAndHolder.getSystemInfo("xiaoka_weixin_secret");
		//		}
		return xiaoka_weixin_secret;
	}

	public void setXiaoka_weixin_secret(String xiaoka_weixin_secret) {
		this.xiaoka_weixin_secret = xiaoka_weixin_secret;
	}

	public String getXiaoka_weixin_token() {
		//		xiaoka_weixin_token = getRedisParamValue("xiaoka_weixin_token");
		//		if (StringUtil.isEmptyOrBlank(xiaoka_weixin_token)) {
		xiaoka_weixin_token = (String) SystemInfoInitAndHolder.getSystemInfo("xiaoka_weixin_token");
		//		}
		return xiaoka_weixin_token;
	}

	public void setXiaoka_weixin_token(String xiaoka_weixin_token) {
		this.xiaoka_weixin_token = xiaoka_weixin_token;
	}

	public String getXiaoka_weixin_aesKey() {
		//		xiaoka_weixin_aesKey = getRedisParamValue("xiaoka_weixin_aesKey");
		//		if (StringUtil.isEmptyOrBlank(xiaoka_weixin_aesKey)) {
		xiaoka_weixin_aesKey = (String) SystemInfoInitAndHolder.getSystemInfo("xiaoka_weixin_aesKey");
		//		}
		return xiaoka_weixin_aesKey;
	}

	public void setXiaoka_weixin_aesKey(String xiaoka_weixin_aesKey) {
		this.xiaoka_weixin_aesKey = xiaoka_weixin_aesKey;
	}

	public String getXiaoka_weixin_oauth2redirectUri() {
		//		xiaoka_weixin_oauth2redirectUri = getRedisParamValue("xiaoka_weixin_oauth2redirectUri");
		//		if (StringUtil.isEmptyOrBlank(xiaoka_weixin_oauth2redirectUri)) {
		xiaoka_weixin_oauth2redirectUri = (String) SystemInfoInitAndHolder
				.getSystemInfo("xiaoka_weixin_oauth2redirectUri");
		//		}
		return xiaoka_weixin_oauth2redirectUri;
	}

	public void setXiaoka_weixin_oauth2redirectUri(String xiaoka_weixin_oauth2redirectUri) {
		this.xiaoka_weixin_oauth2redirectUri = xiaoka_weixin_oauth2redirectUri;
	}

	public String getXiaoka_weixin_api_key() {
		//		xiaoka_weixin_api_key = getRedisParamValue("xiaoka_weixin_api_key");
		//		if (StringUtil.isEmptyOrBlank(xiaoka_weixin_api_key)) {
		xiaoka_weixin_api_key = (String) SystemInfoInitAndHolder.getSystemInfo("xiaoka_weixin_api_key");
		//		}
		return xiaoka_weixin_api_key;
	}

	public void setXiaoka_weixin_api_key(String xiaoka_weixin_api_key) {
		this.xiaoka_weixin_api_key = xiaoka_weixin_api_key;
	}

	public String getXiaoka_weixin_mch_id() {
		//		xiaoka_weixin_mch_id = getRedisParamValue("xiaoka_weixin_mch_id");
		//		if (StringUtil.isEmptyOrBlank(xiaoka_weixin_mch_id)) {
		xiaoka_weixin_mch_id = (String) SystemInfoInitAndHolder.getSystemInfo("xiaoka_weixin_mch_id");
		//		}
		return xiaoka_weixin_mch_id;
	}

	public void setXiaoka_weixin_mch_id(String xiaoka_weixin_mch_id) {
		this.xiaoka_weixin_mch_id = xiaoka_weixin_mch_id;
	}

	public Long getXiaoka_weixin_expiresTime() {
		xiaoka_weixin_expiresTime = Long.valueOf((String) SystemInfoInitAndHolder
				.getSystemInfo("xiaoka_weixin_expiresTime"));
		return xiaoka_weixin_expiresTime;
	}

	public void setXiaoka_weixin_expiresTime(Long xiaoka_weixin_expiresTime) {
		this.xiaoka_weixin_expiresTime = xiaoka_weixin_expiresTime;
	}

}
